@extends('admin_system.layout.layout')

@section('title')
    视频列表页
@stop

@section('content')
    <br>
    <div class="container">
        <div class="panel panel-info">
            <div class="panel-heading">
                <h3 class="panel-title text-center">视频列表</h3>
                <div class="btn-group">
                    <button type="button" class="btn btn-info">
                        <a href="{{route('lessons_list',['lessons_category_id'=>2])}}">直播回顾</a>

                    </button>
                    <button type="button" class="btn btn-danger">
                        <a href="{{route('lessons_list',['lessons_category_id'=>1])}}">学习官必修课</a>
                    </button>
                </div>
            </div>
            <div class="panel-body">
                <table class="table table-condensed table-hover">
                    <thead>
                    <tr>
                        <th>ID</th>
                        <th>title</th>
                        <th>视频地址</th>
                        <th>视频介绍</th>
                        <th>视频封面</th>
                        <th>课程分类</th>
                        <th>课程老师</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    @foreach($data as $k=>$v)
                        <form action="{{route('lessons_save')}}" method="post" id="update_{{$v->id}}">
                            {{csrf_field()}}
                            <tr>
                                <td>
                                    {{$v->id}}
                                    <input type="hidden" value="{{$v->id}}" name="id">
                                </td>
                                <td><input type="text" class="form-control" value="{{$v->title}}" name="title"></td>
                                <td><input type="url" class="form-control" value="{{$v->video_url}}" name="video_url">
                                </td>
                                <td onclick="showIntroduce({{$v->id}})"
                                    style="cursor: pointer">点击进行编辑
                                </td>
                                <td>
                                    <input type="text" class="form-control" value="{{$v->video_img}}" name="video_img">
                                </td>
                                <td>
                                    <select name="lessons_category_id" class="form-control">
                                        @foreach($category as $kk=>$vv)
                                            <option value="{{$vv->id}}"
                                                    @if($v->lessons_category_id==$vv->id)selected @endif >{{$vv->category_name}}</option>
                                        @endforeach
                                    </select>
                                </td>
                                <td>
                                    <input class="form-control" type="text" value="{{$v->user_id}}" style="width: 80px"
                                           name="user_id">
                                </td>
                                <td>
                                    <div class="btn-group">
                                        <button type="button" class="btn btn-danger">
                                            <a href="{{route('lessons_del',['id'=>$v->id])}}">删除</a>
                                        </button>
                                        <button type="button" id="send_update_{{$v->id}}" class="btn btn-info">保存
                                        </button>
                                    </div>
                                </td>
                                @include('admin_system.studyCenter.lessons_modal',['id'=>$v->id,'introduce'=>$v->introduce,'title'=>$v->title])
                            </tr>
                        </form>
                    @endforeach
                    </tbody>
                </table>
                <div class="btn-group">
                    <button type="button" class="btn btn-danger" onclick="showLessonsAdd()">
                        <i class="fa fa-plus"></i>添加
                    </button>
                    @include('admin_system.studyCenter.lessons_modal_add',['category'=>$category])
                </div>
            </div>
            {{$data->appends('lessons_category_id',$type)->links()}}
        </div>
    </div>

    <script>
        @if(session('success'))
        notify_message('{{session('success')}}', 'success')

        @endif

        @if (session('errors'))
        notify_message('{{session('errors')}}', 'success')

        @endif

        function showIntroduce(id) {
            $('#modal-' + id).modal('show');
        }

        function showLessonsAdd() {
            $('#modal-add').modal('show');
        }

        function notify_message(message, type) {

            $.notify({
                icon: 'fa fa-paw',
                message: message,
            }, {
                type: type,
                animate: {
                    enter: "animated fadeInDown",
                    exit: "animated fadeOutUp"
                }
            })
        }

    </script>
@stop
